import { apiUrl } from '@/common/const';
import request from '@/utils/request';

// php 写的接口不分名称，就分参数, 随便写下。。

export const allGet = async ({
  params = {},
  data = {},
  paramsSerializer,
  skipErrorHandler = false,
  headers = {},
}: {
  params?: any;
  data?: any;
  paramsSerializer?: (params) => any;
  skipErrorHandler?: boolean;
  headers?: any;
}) => {
  if (params) {
    params._t = Date.now();
  }
  const response = await request.get<any, { success?: boolean; data?: any; count?: any }>(apiUrl, {
    method: 'GET',
    params,
    data,
    paramsSerializer,
    headers: {
      skipErrorHandler,
      ...headers,
    },
  });
  return response;
};

export const allPost = async ({ params = {}, data = {}, skipErrorHandler = false }) => {
  const response = await request.post<any, { success?: boolean; data?: any }>(apiUrl, data, {
    headers: {
      skipErrorHandler,
    },
  });
  return response;
};
